package com.leetcode.p0;

import com.bean.ListNode;
import com.utils.DataUtils;

public class Test24_digui {

    public ListNode swapPairs(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }

        ListNode newHead = head.next;
        head.next = swapPairs(newHead.next);
        newHead.next = head;

        return newHead;
    }

    public static void main(String[] args) {
//        ListNode listNode1 = DataUtils.getOneToNumberListNode(2);
        ListNode listNode1 = DataUtils.getOneToNumberListNode(21);

        Test24_digui test21 = new Test24_digui();
        ListNode list = test21.swapPairs(listNode1);
        DataUtils.printListNode(list);
    }

}
